// bool, Obj This, Obj other

Hero this;
Unit him;
Building bld;
str cmmd;

this = This.AsHero();
if(!.IsValid()) return false;

cmmd = .command;
if(cmmd == "retreat_notai") return false;
if(cmmd == "retreat_bld_notai") return false;
if(cmmd == "great_charge") return false;
if(.HasItem("irage_battle")) return false;

him = other.AsUnit();
if(him.IsValid()){
	if(!.IsEnemy(him)) return false;
	if(!.IsValidTarget(him)) return false;
	
	return true;
}

bld = other.AsBuilding();
if(bld.IsValid()){
	if(!bld.IsHeirOf("Catapult")) return false;
	if(!.IsEnemy(bld)) return false;
	if(!.IsValidTarget(bld)) return false;
	
	return true;
}

return false;
